package com.alphasta.project.system.ncp.controller;

import com.alphasta.framework.shiro.web.filter.LogoutFilter;
import com.alphasta.framework.web.controller.BaseController;
import com.alphasta.framework.web.page.TableDataInfo;
import com.alphasta.project.system.ncp.entity.*;
import com.alphasta.project.system.ncp.service.NcpPersonInfoService;
import com.alphasta.project.system.ncp.service.SuspectedPersonService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * ncp 可能密切接触者
 *
 * @author alphasta
 */
@Controller
@RequestMapping("/ncp/suspectedPerson")
public class SuspectedPersonController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(LogoutFilter.class);
    private String prefix = "/ncp/suspectedPerson";
    @Autowired
    private SuspectedPersonService suspectedPersonService;
    @RequiresPermissions("ncp:suspectedPerson:view")
    @GetMapping()
    public String ncpPersonInfo()
    {
        return prefix + "/suspectedPerson";
    }
    @RequiresPermissions("ncp:suspectedPerson:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SuspectedPersonFrom suspectedPersonFrom)
    {
        List<SuspectedPersonVOII> data=new ArrayList<>();
        try {
            startPage();
            SuspectedPersonVO suspectedPersonVO = suspectedPersonService.suspectedPerson(suspectedPersonFrom);
            String iscontactperson= suspectedPersonVO.getIscontactperson();
            if("1".equals(iscontactperson)){
                data= suspectedPersonVO.getData();
                return getDataTable(data);
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error("查询出错 e={}",e);
        }
        return getDataTable(data);
    }
}